package com.dobest.aspectdemo;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

import java.util.HashMap;
import java.util.Map;

/**
 * @Package: com.dobest.aspectdemo
 * @author: hujiansong
 * @date: 2018/8/6 14:03
 * @version: V1.0
 */
@ControllerAdvice
@Slf4j
public class GlobaleExceptionHandler {

    @ExceptionHandler(ParamNullException.class)
    public Map<String, Object> requestMissingServletRequest(Exception ex) {
        log.error("ParamNullException", ex);
        Map<String, Object> resp = new HashMap<>(4);
        resp.put("code", -1);
        resp.put("msg", ex.getMessage());
        resp.put("data", null);
        return resp;
    }


}
